<template>
  <!-- 服务列表 -->
  <ul class="serverList">
    <li class="servreItem" v-for="(item,index) in serverList" :key="index" @click="toServerDetail(item)">
      <div class="checkbox" v-if="isEdit">
        <img v-if="item.isChecked" :src="imgOss+'/checked.png'" alt @click="changeChecked(item)" />
        <img v-if="!item.isChecked" :src="imgOss+'/check.png'" alt @click="changeChecked(item)" />
      </div>
      <div class="main">
        <div class="maintop">
          <div class="center">
            <img v-if="item.service_image" :src="imgUrl+item.service_image" alt />
            <!-- 下架 -->
            <img v-if="item.status==0" class="xiajia" :src="imgOss+'/xiajia.png'" alt />
          </div>
          <div class="rt">
            <div class="title">{{item.name}}</div>
            <div class="desc">{{item.service_desc}}</div>
            <div class="bottom">
              <div class="price">
                <span class="red"><span class="yang">¥</span>{{item.price}}</span>
                <span><span class="yang">¥</span><span class="oldprice">{{item.origin_price}}</span></span>
              </div>
              <div class="sales">已售{{item.sale_num}}</div>
            </div>
          </div>
        </div>
         <div class="mainbottom">
            <img :src="imgOss+'/collection/plus.png'" alt="">
            <span>{{item.plus_title}}</span>
        </div>
      </div>
    </li>
  </ul>
</template>

<script>
import common from "@/assets/js/mmk_common.js";
export default {
  components: {},
  props: {
    isEdit: false,
    serverList: []
  },
  data() {
    return {
      imgUrl: common.image_response,
      imgOss: common.image_resource
    };
  },
  watch: {
    serverList(newval, oldval) {
      this.serverList = newval;
    }
  },
  computed: {},
  methods: {
    changeChecked(item) {
      item.isChecked = !item.isChecked;
      this.$emit("serverClick", this.serverList);
    },
    // 服务详情
    toServerDetail(item) {
      if (item.status == 0) {
        return;
      }
      let router = encodeURIComponent(
        `serviceDetail?serviceId=${item.shop_id}`
      );
      wx.navigateTo({ url: `/pages/life_beauty/main?router=${router}` });
    }
  }
};
</script>
<style lang="less" scoped>
.serverList {
  padding: 10px;
  box-sizing: border-box;
}
.servreItem {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  margin-bottom: 10px;
}
.checkbox {
  width: 20px;
  height: 20px;
  margin-right: 15px;
  img {
    width: 20px;
    height: 20px;
  }
}
.main {
  width: 100%;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0px 2px 6px 0px rgba(240, 240, 240, 1);
  border-radius: 5px;
  .maintop{
    padding: 10px 10px 0;
    display: flex;
    box-sizing: border-box;
    .center {
      width:68px;
      height:68px;
      border-radius: 5px;
      position: relative;
      img{
        width: 100%;
        height: 100%;
        border-radius: 5px;
      }
      .xiajia {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 11;
      }
    }
    .rt {
      flex: 7;
      margin-left: 10px;
      overflow: hidden;
      position: relative;
      .title {
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #1d2023;
        line-height: 17px;
        margin-bottom: 5px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      .desc {
        font-size: 12px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #606972;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
      }
      .bottom {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 2px;
        .price {
          font-family: PingFangSC-Semibold, PingFang SC;
          font-weight: 400;
          font-size: 14px;
          color: #78828c;
          .red {
            font-size: 18px;
            font-weight: 500;
            color: #FF383E;
            margin-right: 6px;
            .yang {
              font-size: 12px;
            }
          }
          .oldprice{
            text-decoration:line-through
          }
        }
        .sales {
          font-size: 12px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #78828c;
          line-height: 16px;
        }
      }
    }
  }
  .mainbottom{
    padding: 10px;
    box-sizing: border-box;
    img{
      width:29px;
      height:16px;
      vertical-align: -4px;
    }
    span{
      margin-left: 4px;
      font-size:12px;
      font-family:PingFangSC-Regular,PingFang SC;
      font-weight:400;
      color:rgba(102,102,102,1);
      line-height:16px;
    }
  }
}
</style>